<?php
namespace app\api\controller\v1;
use app\api\controller\Common;

class Evas extends Common{
	var $modelDb;
	public function _initialize(){
		parent::_initialize();
		$this->modelDb = model("Evas");
	}
	public function add(){
		$this->postData['userid'] = $this->uinfo['id'];
		$id = $this->modelDb->save_data($this->postData);
		if (!$id) {
			return $this->app_error($this->modelDb->getError());
		}
		if ($this->postData['typeid'] == 1) {
			model('Requires')->where('id',$this->postData['contentid'])->setInc('evas');
		}else{
			model('MemberCredit')->set_evas($this->postData['contentid'], $this->postData['score'], $this->postData['typeid'] - 1);
		}
		return $this->app_success();
	}
}